from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from ament_index_python.packages import get_package_share_directory
import os

def generate_launch_description():
    # 声明参数
    declare_method_arg = DeclareLaunchArgument(
        'method', 
        default_value='standard',
        description='Method to determine the topic name'
    )

    return LaunchDescription([
        declare_method_arg,
        # 控制节点
        Node(
            package='control',
            executable='control',
            name='control',
            parameters=[{'method': LaunchConfiguration('method')}],
            output='screen'
        ),
        # 替换为 server_node 节点
        Node(
            package='bridge4go2w_pkg',  # 指定 server_node 所在的包
            executable='server_node',   # 可执行文件名（需与 setup.py/CMakeLists 配置一致）
            name='server_node',         # 节点名称
            output='screen'
        )
    ])